 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head lang="en" th:replace="include/common/common :: commonHeader">
    <footer th:include="include/common/common :: layUiResource"></footer>
    <footer th:include="include/common/common :: blueCSSResource"></footer>
    <footer th:include="include/common/common :: zTreeCSSSource"></footer>
    <footer th:include="include/common/common :: zTreeJSSource"></footer>
    <script>
        layui.config({
            base: '/staticResource/layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index','form'] , function () {
            var admin = layui.admin
                ,element = layui.element
                ,form = layui.form;

            element.render();

            let entityName = 'supplier';
            $(document).ready(function () {
                $.fn.blueJs.tools.formButtonItem(entityName);
            });

            //点击事件监听
            $(document).on('click' , function (event) {
                let targetId = event.target.id;
                let cancelBtn = entityName + "CancelBtn";
                if (targetId == cancelBtn){
                    let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                }
            });

            $(document).on('click','.zTreeBtn' , function () {
                $("#zTreeOption").val($(this).attr('data'));
                let elementId = $(this).attr('id') , data = JSON.parse($(this).attr('data')) , i = '/a/layTips/treeSelectForm?isUpdateTree=false' , t = data.title;


                $.fn.blueJs.tools.active['layerOpen'].call(this , i , t);
            });

            form.on('submit(supplierSave)',function () {
                let regExp = /[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}/;
                let tax = $("#tax").val() , license = $("#license").val();
                if (!regExp.test(tax) || !regExp.test(license)){
                    alert("纳税识别号或者营业执照信息填写不正确，请确认！");
                }else {
                    let msg = $.fn.blueJs.tools.formSubmit(this)
                        ,type = 'saveMsg';
                    //当你在iframe页面关闭自身时
                    let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    $.fn.blueJs.tools.active[type].call(this , msg , index);
                }
                return false;
            });

        });


    </script>
</head>
<body>
<!--  zTree遮罩层 -->
<input type="hidden" id="zTreeOption" value=""/>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <form class="layui-form" id="supplierForm" th:object="${supplier}" method="post" action="/a/supplier/save">
                        <div class="blue-form-unit">基本信息</div>
                        <input type="hidden" name="id" id="configId" th:field="*{id}"/>
                        <input type="hidden" name="isNewRecord" th:field="*{isNewRecord}"/>

                        <div class="layui-form-item">
                            <div class="layui-col-md6">
                                <label class="layui-form-label " title=""><span class="blue-required ">*</span>代码：</label>
                                <div class="layui-input-block">
                                    <input type="text" class="layui-input" lay-verify="required" placeholder="请输入代码" id="code" th:field="*{code}">
                                </div>
                            </div>

                            <div class="layui-col-md6">
                                <label class="layui-form-label " title=""><span class="blue-required ">*</span>名称：</label>
                                <div class="layui-input-block">
                                    <input type="text" class="layui-input" lay-verify="required" placeholder="请输入名称" id="name" th:field="*{name}">
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-col-md6">
                                <label class="layui-form-label " title=""><span class="blue-required hide">*</span>纳税识别号：</label>
                                <div class="layui-input-block">
                                    <input type="text" class="layui-input" lay-verify="" placeholder="" id="tax" th:field="*{tax}">
                                </div>
                            </div>

                            <div class="layui-col-md6">
                                <label class="layui-form-label " title=""><span class="blue-required hide">*</span>营业执照代码：</label>
                                <div class="layui-input-block">
                                    <input type="text" class="layui-input" lay-verify="" placeholder="" id="license" th:field="*{license}">
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-col-md6">
                                <label class="layui-form-label " title=""><span class="blue-required hide">*</span>联系电话：</label>
                                <div class="layui-input-block">
                                    <input type="text" class="layui-input" lay-verify="" placeholder="" id="tel" th:field="*{tel}">
                                </div>
                            </div>

                            <div class="layui-col-md6">
                                <label class="layui-form-label " title=""><span class="blue-required hide">*</span>联系地址：</label>
                                <div class="layui-input-block">
                                    <input type="text" class="layui-input" lay-verify="" placeholder="" id="address" th:field="*{address}">
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-col-md12">
                                <label class="layui-form-label " title=""><span class="blue-required hide">*</span>备注：</label>
                                <div class="layui-input-block">
                                    <textarea name="remarks" rows="4" maxlength="500" class="layui-textarea" th:text="*{remarks}"></textarea>
                                </div>
                            </div>
                        </div>

                        <!-- Form 按钮组-->
                        <div class="layui-form-item layui-layout-admin">
                            <div class="layui-input-block blue-form-button-item"></div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>




